<script>
    //构建搜索框   
    function builderSearch(data,layer) {
        var html = '';
        if (data instanceof Array && data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                //页面url参数值替换表单默认值
                var paramValue = get_url_param_value(data[i].name);
                data[i].value = paramValue == null ? data[i].value : unescape_text(paramValue);
                switch (data[i].type) {
                    //隐藏属性
                    case "hidden":
                        html += '<input type="hidden" name="' + data[i].name + '" value="' + data[i].value + '">';
                        break;
                    //文本搜索模板
                    case 'text':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        break;
                    //日期时间搜索模板  
                    case 'year':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" id="search_datetime_' + data[i].name + '" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        html += '<script>layui.use("laydate", function(){var laydate = layui.laydate;laydate.render({elem: "#search_datetime_' + data[i].name + '",type: "year",calendar: true,theme: "grid", trigger: "click",lang:"cn"});});<\/script>';
                        break;
                    //月份时间搜索模板  
                    case 'month':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" id="search_datetime_' + data[i].name + '" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        html += '<script>layui.use("laydate", function(){var laydate = layui.laydate;laydate.render({elem: "#search_datetime_' + data[i].name + '",type: "month",calendar: true,theme: "grid",  trigger: "click",lang:"cn"});});<\/script>';
                        break;
                    //日期时间搜索模板  
                    case 'date':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" id="search_datetime_' + data[i].name + '" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        html += '<script>layui.use("laydate", function(){var laydate = layui.laydate;laydate.render({elem: "#search_datetime_' + data[i].name + '",type: "date",calendar: true,theme: "grid", min: "1980-01-30",max: "2050-01-30", trigger: "click",lang:"cn"});});<\/script>';
                        break;
                    //时间搜索模板  
                    case 'time':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" id="search_datetime_' + data[i].name + '" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        html += '<script>layui.use("laydate", function(){var laydate = layui.laydate;laydate.render({elem: "#search_datetime_' + data[i].name + '",type: "time",calendar: true,theme: "grid", min: "00:00:00",max: "23:59:59", trigger: "click",lang:"cn"});});<\/script>';
                        break;
                    //日期时间搜索模板  
                    case 'datetime':
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<input type="text" id="search_datetime_' + data[i].name + '" name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input" value="' + data[i].value + '">' +
                            '</div>' +
                            '</div>';
                        html += '<script>layui.use("laydate", function(){var laydate = layui.laydate;laydate.render({elem: "#search_datetime_' + data[i].name + '",type: "datetime",calendar: true,theme: "grid", min: "1980-01-30 00:00:00",max: "2050-01-30 00:00:00", trigger: "click",lang:"cn"});});<\/script>';
                        break;
                    //下拉选择模板    
                    case 'select':
                        //初始选项
                        var options = '<option value="">' + data[i].placeholder + '</option>';

                        for (var j = 0; j < data[i].options.length; j++) {
                            if (data[i].options[j].value == data[i].value) {
                                options += '<option value="' + data[i].options[j].value + '" selected>' + data[i].options[j].title + ' </option>'
                            } else {
                                options += '<option value="' + data[i].options[j].value + '">' + data[i].options[j].title + ' </option>'
                            }
                        }

                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<select name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input"   lay-search="">' +
                            options +
                            '</select>' +
                            '</div>' +
                            '</div>';
                        break;
                    case 'selectgroup':
                        //初始选项
                        var options = '<option value="">' + data[i].placeholder + '</option>';
                        for (var j = 0; j < data[i].options.length; j++) {
                            options += '<optgroup label="' + data[i].options[j].title + '">';
                            for (var k = 0; k < data[i].options[j].options.length; k++) {
                                if (data[i].options[j].options[k].value == data[i].value) {
                                    options += '<option value="' + data[i].options[j].options[k].value + '" selected>' + data[i].options[j].options[k].title + ' </option>'
                                } else {
                                    options += '<option value="' + data[i].options[j].options[k].value + '">' + data[i].options[j].options[k].title + ' </option>'
                                }
                            }
                            options += ' </optgroup>';
                        }
                        html += '<div class="layuiadmin-mb-10 ' + data[i].layout + '">' +
                            '<label class="layui-form-label">' +
                            data[i].title + '：' +
                            '</label>' +
                            '<div class="layui-input-block">' +
                            '<select name="' + data[i].name + '" placeholder="' + data[i].placeholder + '" autocomplete="off" class="layui-input"   lay-search="">' +
                            options +
                            '</select>' +
                            '</div>' +
                            '</div>';
                        break;
                    default:
                        var log = '搜索类型不存在：' + data[i].type;
                        layer.msg(log, function () { });
                        console.log(log + ";\n",);
                        console.log("错误的搜索类型数据：" + data[i]);
                        console.log("当前支持的搜索类型：hidden,text,year,month,data,time,datetime,select,selectgroup");
                        break;
                }
            }
        }
        if (html !== '') {

            html = '<form class="layui-form"  action="">' + html;
            html += '<div class="layuiadmin-mb-10 layui-col-xs-offset0 layui-col-sm-offset0 layui-col-md-offset0 layui-col-lg-offset0 layui-col-space0 layui-col-lg4 layui-col-md4 layui-col-sm12 layui-col-xs12"><label class="layui-form-label"></label><div class="layui-input-block"><button class="layui-btn" lay-submit lay-filter="layui_search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></button></div></div>';
            html += '</form>';

            html += '<script>layui.use(["form"], function(){var form = layui.form;form.render();});<\/script>';
        }
        $(".layuiadmin-search").html(html);
      
    }
</script>